package com.kantboot.business.water.domain.entity;


import com.kantboot.system.user.domain.entity.SysUser;
import com.kantboot.util.core.jpa.KantbootGenerationType;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 水订单表
 */
@Entity
@Getter
@Setter
@Table(name = "bus_water_goods_order")
@Accessors(chain = true)
@EntityListeners(AuditingEntityListener.class)
@DynamicUpdate
@DynamicInsert
@NoArgsConstructor
public class BusWaterGoodsOrder implements Serializable {

    /**
     * 订单状态编码
     * 配送中
     */
    public static final String ORDER_STATUS_CODE_IN_DELIVERY = "inDelivery";

    /**
     * 订单状态编码
     * 未提
     */
    public static final String ORDER_STATUS_CODE_NOT_PROVIDED = "notProvided";

    /**
     * 订单状态编码
     * 已提
     */
    public static final String ORDER_STATUS_CODE_PROVIDED = "provided";

    /**
     * 支付订单id
     */
    @Column(name = "pay_order_id")
    private Long payOrderId;

    /**
     * 支付订单状态编码
     */
    @Column(name = "pay_order_status_code")
    private String payOrderStatusCode;

    /**
     * 主键
     */
    @Id
    @GenericGenerator(name = "snowflakeId", strategy = KantbootGenerationType.SNOWFLAKE)
    @GeneratedValue(generator = "snowflakeId")
    @Column(name = "id")
    private Long id;

    /**
     * 创建时间
     */
    @CreatedDate
    @Column(name = "gmt_create")
    private Date gmtCreate;

    /**
     * 修改时间
     */
    @LastModifiedDate
    @Column(name = "gmt_modified")
    private Date gmtModified;

    /**
     * 商品Id
     */
    @Column(name = "goods_id", length = 64)
    private Long goodsId;


    /**
     * 商品数量
     */
    @Column(name = "goods_number")
    private Long goodsNumber;


    @OneToOne
    @JoinColumn(name = "goods_id", referencedColumnName = "id", insertable = false, updatable = false)
    private BusWaterGoods waterGoods;

    /**
     * 订单状态编码
     * 配送中 【后台修改,核销人 已到达】 -> 未提 【核销】->  已提
     * 驼峰式命名
     * 配送中 inDelivery
     * 未提 notProvided
     * 已提 provided
     */
    @Column(name = "order_status_code")
    private String orderStatusCode;

    /**
     * 送水点
     */
    @Column(name = "water_lifting_point_id")
    private Long waterLiftingPointId;

    @OneToOne
    @JoinColumn(name = "water_lifting_point_id", referencedColumnName = "id", insertable = false, updatable = false)
    private BusWaterLiftingPoint waterLiftingPoint;

    /**
     * 消费者的用户id
     */
    @Column(name = "user_id_of_consumer")
    private Long userIdOfConsumer;

    /**
     * 消费者的手机号
     */
    @Column(name = "phone_of_consumer")
    private String phoneOfConsumer;

    /**
     * 消费者的姓名
     */
    @Column(name = "name_of_consumer")
    private String nameOfConsumer;

    @OneToOne
    @JoinColumn(name = "user_id_of_consumer", referencedColumnName = "id", insertable = false, updatable = false)
    private SysUser userOfConsumer;

    /**
     * 核销人员的用户id
     */
    @Column(name = "user_id_of_verifier")
    private Long userIdOfVerifier;

    @OneToOne
    @JoinColumn(name = "user_id_of_verifier", referencedColumnName = "id", insertable = false, updatable = false)
    private SysUser userOfVerifier;

    /**
     * 原价金额
     */
    @Column(name = "original_money")
    private BigDecimal originalMoney;

    /**
     * 减免金额
     */
    @Column(name = "discount_money")
    private BigDecimal discountMoney;

    /**
     * 付款金额
     */
    @Column(name = "pay_money")
    private BigDecimal payMoney;

    /**
     * 数量
     */
    @Column(name = "number")
    private Long number;

    /**
     * 可得积分
     */
    @Column(name = "integral")
    private Long integral;


}
